package com.sam.im.heiqun.uis.widgets;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;

import com.sam.im.heiqun.R;

public class ChatBottomView extends LinearLayout {
    private View baseView;
    private LinearLayout imageGroup;
    private LinearLayout cameraGroup;
    private LinearLayout phraseGroup;
    private LinearLayout redpacketGroup;
    private LinearLayout transferGroup;
    private LinearLayout locationLayout;//定位
    private LinearLayout videoLayout;//视频
    private LinearLayout fileGrop ; //文件
    private LinearLayout aacolaction ;//AA收款
    private HeadIconSelectorView.OnHeadIconClickListener onHeadIconClickListener;
    public static final int FROM_CAMERA = 0;
    public static final int FROM_GALLERY = 2;
    public static final int FROM_PHRASE = 3;
    public static final int FROM_REDPACKET = 4;
    public static final int FROM_TRANSFER = 5;
    public static final int FROM_LOCATION = 6;
    public static final int FROM_FILE = 7;
    public static final int FROM_VIDEIO = 8 ;
    public static final int FROM_AA = 9;
    public ChatBottomView(Context context, AttributeSet attrs) {
        super(context, attrs);
        findView();
        init();
    }
    private void findView() {
        baseView = LayoutInflater.from(getContext()).inflate(R.layout.layout_tongbaobottom, this);
        imageGroup = (LinearLayout) baseView.findViewById(R.id.image_bottom_group);
        cameraGroup = (LinearLayout) baseView.findViewById(R.id.camera_group);
        phraseGroup = (LinearLayout) baseView.findViewById(R.id.phrase_group);
        redpacketGroup = (LinearLayout) baseView.findViewById(R.id.red_packet);
        transferGroup = (LinearLayout) baseView.findViewById(R.id.transfer_accounts);
        locationLayout = (LinearLayout) baseView.findViewById(R.id.location_layout);
        videoLayout = (LinearLayout) baseView.findViewById(R.id.video_layout);
        fileGrop = (LinearLayout) baseView.findViewById(R.id.send_file);
        aacolaction = (LinearLayout) baseView.findViewById(R.id.aa_collection);
    }

    private void init() {
        aacolaction.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                if (null != onHeadIconClickListener) {
                    onHeadIconClickListener.onClick(FROM_AA);
                }
            }
        });
        cameraGroup.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                if (null != onHeadIconClickListener) {
                    onHeadIconClickListener.onClick(FROM_CAMERA);
                }
            }
        });
        imageGroup.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {

                if (null != onHeadIconClickListener) {
                    onHeadIconClickListener.onClick(FROM_GALLERY);
                }
            }
        });
        phraseGroup.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {

                if (null != onHeadIconClickListener) {
                    onHeadIconClickListener.onClick(FROM_PHRASE);
                }
            }
        });
        redpacketGroup.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {

                if (null != onHeadIconClickListener) {
                    onHeadIconClickListener.onClick(FROM_REDPACKET);
                }
            }
        });
        transferGroup.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {

                if (null != onHeadIconClickListener) {
                    onHeadIconClickListener.onClick(FROM_TRANSFER);
                }
            }
        });
        locationLayout.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {

                if (null != onHeadIconClickListener) {
                    onHeadIconClickListener.onClick(FROM_LOCATION);
                }
            }
        });
        fileGrop.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                if (null != onHeadIconClickListener) {
                    onHeadIconClickListener.onClick(FROM_FILE);
                }
            }
        });
        videoLayout.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                if (null != onHeadIconClickListener) {
                    onHeadIconClickListener.onClick(FROM_VIDEIO);
                }
            }
        });
    }

    public void setOnHeadIconClickListener(
            HeadIconSelectorView.OnHeadIconClickListener onHeadIconClickListener) {
        this.onHeadIconClickListener = onHeadIconClickListener;
    }
}
